package com.wingsboat;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * @author wangzhong
 * @description: TODO 集群负载统计
 * @date 2024/7/19 22:43
 */
public class Test2 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        List<List<String>> urls = new ArrayList<>();
        while(count>=0){
            String url = scanner.nextLine();
            if(url.length()>0){
                List<String> collect = Arrays.stream(url.split("/")).collect(Collectors.toList());
                urls.add(collect);
            }
            count = count - 1;
        }
        String str = scanner.nextLine();
        String[] arr = Arrays.stream(str.split(" ")).toArray(String[]::new);
        int level = Integer.valueOf(arr[0]);
        String cp = arr[1];
        int result = 0;
        for (List<String> url : urls) {
            if(url.size()>level){
                if(url.get(level).equals(cp)){
                    result+=1;
                }
            }
        }
        System.out.println(result);
    }
}
